<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
const kStyle = 'div, img { width: 200px; height: 100px; }';
selection_test(
    [
        `<style>${kStyle}</style>`,
        '<div contenteditable id="target"></div>',
        '^<img id="image">|',
    ],
    selection => {
        if (!window.eventSender)
          throw 'This test requires eventSender.';

        const image = selection.document.getElementById('image');
        eventSender.mouseMoveTo(
            selection.computeLeft(image) + 30,
            selection.computeTop(image) + 30);
        eventSender.mouseDown();

        const target = selection.document.getElementById('target');
        eventSender.mouseMoveTo(
            selection.computeLeft(target) + 30,
            selection.computeTop(target) + 30);
        eventSender.mouseUp();
    },
    [
        `<style>${kStyle}</style>`,
        '<div contenteditable id="target">',
            '^<img id="image">|',
        '</div>',
        '<img id="image">',
    ]);
</script>
